package com.uqbar.pacman.components;

import com.uqbar.pacman.scenes.PacmanScene;
import com.uqbar.vainilla.DeltaState;
import com.uqbar.vainilla.GameComponent;
import com.uqbar.vainilla.colissions.CollisionDetector;

public abstract class PacDot extends GameComponent<PacmanScene> {

	private int score;

	public int getScore() {
		return score;
	}

	public void setScore(int score) {
		this.score = score;
	}
	
	public void update(DeltaState deltaState) {

		if(this.esComido(this.getScene().getPacman())){
			this.getScene().getMarcador().hit();
			this.destroy();
		}
		
		super.update(deltaState);

		
	}
	
	
	public boolean esComido(Pacman pacman){
		return CollisionDetector.INSTANCE.collidesCircleAgainstCircle(
				this.getX(), this.getY(), 
				(int) this.getAppearance().getWidth() / 2, pacman.getX(),
				pacman.getY(), (int) pacman.getAppearance().getWidth() / 2);
	}

}
